<?php

class style
{

	//if one column everything goes into the left one
	var $leftPane = array();
	var $leftCount = 1;
	var $rightPane = array();
	var $rightCount = 1;
        var $javascript = array();
        var $headers = "";
	
	var $advertisement;
	
	var $is_twoSided;
	
	function style($type)
	{
		if($type)
		{
			$this->is_twoSided = true;
		}
		else
		{
			$this->is_twoSided = false;
		}
		
		include_once('includes/partner_block.php');
		$this->advertisement = new partner_block();
	}	
		
	function addRenderLeft($item)
	{
		
		$this->leftPane[$this->leftCount] = $item;
		$this->leftCount = $this->leftCount + 1;
		
	}

        function addJavascript($url)
        {
            $this->javascript[] = $url;
        }
	
	//adds items to left pane if we're not two sided
	function addRenderRight($item)
	{
		if($this->is_twoSided)
		{
			$this->rightPane[$this->rightCount] = $item;
			$this->rightCount = $this->rightCount + 1;
		}
		else
		{
			$this->leftPane[$this->leftCount] = $item;
			$this->leftCount = $this->leftCount + 1;
		}
	}

        function addHeader($item)
        {
            $this->headers .= $item;
        }

	//renders the main block
	function render()
	{					
		global $skin_dir, $lang;
		
		//get left pane contents
		ob_start();
		for($x = 1; $x < $this->leftCount; $x += 1)
		{
			$this->leftPane[$x]->render();
		}
		$leftPaneContents = ob_get_contents();
		ob_end_clean();
		
                $jsincludes = '';
                foreach($this->javascript as $jsitem)
                {
                    $jsincludes .= "<script type=\"text/javascript\" src=\"{$jsitem}\"></script>";
                }
		//render content
		if($this->is_twoSided)
		{	
			//get right pane contents
			ob_start();
			for($x = 1; $x < $this->rightCount;  $x += 1)
			{
				$this->rightPane[$x]->render();
			}
			$rightPaneContents = ob_get_contents();
			ob_end_clean();

                        $header = $this->headers;
			
			//render the header
			include_once("./includes/header.php");
			include($skin_dir.'tpl/twoSides.tpl');
		}
		else
		{
                        $header = $this->headers;
                        
			//render the header
			include_once("./includes/header.php");
			include($skin_dir.'tpl/oneSide.tpl');
		}
		
		$this->advertisement->render();
		
		//render footer
		include_once("./includes/footer.php");
	}
}
?>